#include "StdAfx.h"
#include "dmAddInPrj2AddIn.h"
#include "DemoOperator.h"
#include "dmLib.h"
#include "th_md.h"
#include "w60lncps.h"
#include "hdimineview.h"
#include "HDiMineModel.h"
#include "MSUtility.h"
#include "dmdbbase.h"
#include "dmentitybase.h"
#include "dmLayerBase.h"
#include "SelectOperator.h"
#include "SelectionSet.h"
#include "SelectionItem.h"
#include "dmFeatureSet.h"

CDemoOperator::CDemoOperator(HDiMineView *view,IDMAddIn*addin):
	CAddInBaseOperator(view,addin)
{
	init();
}

int CDemoOperator::init()
{
	dmDbSpline* spline=dmDbSpline::New();
	dmEntityPtr ptr=(const dmDbSpline*)spline;
	return CAddInBaseOperator::Init();
}
int CDemoOperator::OnLButtonDown(dmEventInfo &hevent)
{
	Relegate(new CSelectOperator(m_pView,this,&hevent,SEL_NURBS));
	return CBaseOperator::OnLButtonDown(hevent);
}
void CDemoOperator::Resume(void *pUserData)
{
	CSelectionSet* sets= m_pView->GetSelection();
	CSelectItem* item=sets->GetItemAt(0);
	if(item!=0)
	{
		dmDbEntity *entity= item->GetEntity();
		dmDbSpline *spline=dmDbSpline::SafeDownCast(entity);
		if(spline!=0)
		{
			int degree,cpcount,weights_count,knots_count;
			dmDPoint *control_points=0;
			double *weights=0;
			double *knots=0;
			double start,end;
			spline->GetGraphData(degree,cpcount,control_points,weights_count,weights,knots_count,knots,start,end);
			dmDbSpline *line=dmDbSpline::New();
			line->SetGraphData(degree,cpcount,control_points,weights_count,weights,knots_count,knots,start,end);
			dmPolyData *data=dmPolyData::New();
			line->ToPolyData(data);
			int num=data->GetNumberOfPoints();
			int aa=0;
		}
	}
}